<template>
  <div>
<el-dialog
  title="
  编辑"
  v-model="editDialogVisble"
  width="30%"
  center>
 <el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="数目">
    <el-input v-model="form.income"></el-input>
  </el-form-item>
    <el-form-item label="描述">
    <el-input v-model="form.describe"></el-input>
  </el-form-item>
    <el-form-item label="支付方式">
    <el-input v-model="form.income"></el-input>
  </el-form-item>

  <el-form-item label="类型">
    <el-radio-group v-model="form.type">
      <el-radio :label="0" >收入</el-radio>
      <el-radio :label="1">支出</el-radio>
    </el-radio-group>
  </el-form-item>
  <el-form-item label="支付方式">
    <el-radio-group  v-model="form.cash">
      <el-radio label="现金"  ></el-radio>
      <el-radio  label="微信"></el-radio>
      <el-radio  label="支付宝"></el-radio>
    </el-radio-group>
  </el-form-item>
</el-form>
  <template #footer>
    <span class="dialog-footer">
      <el-button @click="editDialogVisble = false">取 消</el-button>
      <el-button type="primary" @click="confirmeditprofile">确 定</el-button>
    </span>
  </template>

</el-dialog>
  </div>
</template>

<script>
import {reqeditprofile} from "@api/profile.js" 
import { mapMutations } from 'vuex';
export default {
name:'editProfile',
data(){
    return {
        editDialogVisble:false,
        form:{
            type:0,
            income:"",
            expend:"",
            cash:"现金",
            remark:"",
            describe:"",
            _id:""
        },
        index:null  //要修改的参数位置
    }
},
methods:{
    ...mapMutations({
        editProfile:"editProfile"
    }),
    // 打开修改框
    openEditDialog(data){
        console.log("获取的参数", data);
        this.form.type=data.row.type
        this.form.income=data.row.income
        this.form.expend=data.row.expend
        this.form.cash=data.row.cash
          this.form.remark=data.row.remark
        this.form.describe=data.row.describe
         this.form._id=data.row._id
        this.editDialogVisble=true
        this.index=data.index
    },
   async confirmeditprofile(){
     const result=  await reqeditprofile(this.form,{},{headers: {'Content-Type': 'application/x-www-form-urlencoded'},})
      this.editProfile({index:this.index,form:result})
       if (result) {
          this.editDialogVisble=false  
        }

    }
}
}
</script>

<style>

</style>